package com.qj.daibei.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qj.daibei.mapper.AccountMapper;
import com.qj.daibei.pojo.User;
import com.qj.daibei.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AccountServiceImpl extends ServiceImpl<AccountMapper, User> implements AccountService {
    @Autowired
    AccountMapper accountMapper;

    @Override
    public User queryUserById(Integer userId) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",userId);
        return accountMapper.selectOne(queryWrapper);
    }

    @Override
    public void updateUserById(User user) {
        UpdateWrapper<User> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("user_id",user.getUserId());
        accountMapper.update(user,updateWrapper);
    }
}
